package com.guonl.controller;

import com.alibaba.fastjson.JSONObject;
import com.guonl.controller.model.UserModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by guonl
 * Date 2020/5/31 4:40 PM
 * Description:
 */
@Api(tags = "我的测试")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation(value = "查询访问者")
    @GetMapping("/{name}")
    public ResponseEntity<String> test(@PathVariable String name){

        return ResponseEntity.ok("请求成功！名字是：" + name);
    }

    @ApiOperation(value = "查询用户")
    @GetMapping("/user")
    public ResponseEntity<String> test(UserModel user){
        String json = JSONObject.toJSONString(user);
        return ResponseEntity.ok("请求成功！请求用户：" + json);
    }


}
